<template>
  <div class="ai-clothes-card" @click="$emit('click')">
    <div class="ai-clothes-image-container">
      <img :src="item.image" :alt="item.name" class="ai-clothes-image">
      <div class="ai-clothes-actions">
        <a :href="item.productUrl" target="_blank" class="ai-action-button view" @click.stop>
          <eye-outlined />
        </a>
      </div>
    </div>
    <div class="ai-clothes-info">
      <div class="ai-clothes-category">{{ getCategoryName(item.categoryId) }}</div>
      <h4 class="ai-clothes-name">{{ item.name }}</h4>
      <p class="ai-clothes-description">{{ item.description }}</p>
      <div class="ai-clothes-meta">
        <span class="ai-clothes-price">¥{{ item.price }}</span>
        <a :href="item.productUrl" target="_blank" class="ai-clothes-link" @click.stop>查看详情</a>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue'
import { EyeOutlined } from '@ant-design/icons-vue'

defineProps({
  item: {
    type: Object,
    required: true
  }
})

defineEmits(['click'])

const getCategoryName = (categoryId) => {
  const categoryMap = {
    '1': '上衣',
    '2': '裙装',
    '3': '裤装',
    '4': '外套',
    '5': '鞋子',
    '6': '手表',
    '7': '装饰'
  }
  return categoryMap[categoryId?.toString()] || '其他'
}
</script>

<style scoped>
.ai-clothes-card {
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.3s;
  border: 1px solid #f1f5f9;
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.ai-clothes-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.ai-clothes-image-container {
  position: relative;
  width: 100%;
  height: 50%;
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
}

.ai-clothes-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ai-clothes-info {
  padding: 0.375rem;
  height: 50%;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  background-color: #ffffff;
}

.ai-clothes-category {
  font-size: 0.625rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  white-space: nowrap;
  align-self: flex-start;
}

.ai-clothes-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #1e293b;
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-clothes-description {
  font-size: 0.625rem;
  color: #64748b;
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 0;
  margin-bottom: 0.125rem;
}

.ai-clothes-price {
  font-size: 0.75rem;
  color: #ef4444;
  font-weight: 600;
  margin-right: auto;
}

.ai-clothes-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
  border-top: 1px solid #f1f5f9;
}

.ai-clothes-link {
  font-size: 0.625rem;
  color: #3498db;
  text-decoration: none;
  transition: color 0.3s;
}

.ai-clothes-link:hover {
  color: #2980b9;
  text-decoration: underline;
}

.ai-clothes-actions {
  position: absolute;
  top: 0.125rem;
  right: 0.125rem;
  display: flex;
  gap: 0.125rem;
  opacity: 0;
  transition: all 0.3s;
}

.ai-clothes-card:hover .ai-clothes-actions {
  opacity: 1;
}

.ai-action-button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.3s;
  font-size: 0.625rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  text-decoration: none;
}

.ai-action-button:hover {
  background: #ffffff;
  color: #0ea5e9;
  transform: scale(1.1);
}

@media (max-width: 480px) {
  .ai-clothes-image-container {
    padding: 0.25rem;
  }

  .ai-clothes-info {
    padding: 0.25rem;
  }

  .ai-clothes-name {
    font-size: 0.625rem;
  }

  .ai-clothes-description {
    font-size: 0.5625rem;
  }

  .ai-clothes-category {
    font-size: 0.5625rem;
  }

  .ai-action-button {
    width: 18px;
    height: 18px;
    font-size: 0.5625rem;
  }
}
</style> 